﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Summerset.Isbndb.Subjects
{
    /// <summary>
    /// Shows a list of categories this subject is listed in.
    /// </summary>
    public sealed class SubjectElementCategory : ResponseElementChildBase
    {
        /* Example Element:
         * <Category category_id="society.interpersonal_relations.love.poetry">Poetry</Category> */

        #region Constructor + Overridden Properties

        /// <summary>
        /// Initializes a new instance of the <see cref="SubjectElementCategory"/> class.
        /// </summary>
        /// <param name="categoryElement">The xml element containing the underlying data for this instance.</param>
        public SubjectElementCategory(XmlElement categoryElement) 
            : base(categoryElement) { }
    
        /// <summary>
        /// Gets the name of the XML element expected by this class's constructor.  
        /// </summary>
        protected override string  ExpectedElementName
        {
	        get { return "Category"; }
        }

        #endregion
        #region Properties

        /// <summary>
        /// Returns a string that uniquely-identifies this category to the ISBNDB.com API.
        /// </summary>
        /// <remarks>
        /// This string can be used to request more detailed information on this category
        /// from the categories collection.  
        /// </remarks>
        public string CategoryId
        {
            get { return _element.Attributes["category_id"].Value; }
        }

        /// <summary>
        /// Gets a short textual identifier for this category.  Ex, 'Poetry'
        /// </summary>
        public string Text
        {
            get { return _element.InnerText; }
        }

        #endregion
    }
}
